﻿using RpcCacheClient;
using RpcCacheClient.Cache;
using RpcCacheClient.Config;
using RpcCacheClient.Interface;
using RpcCacheClient.Local;
using RpcCacheClient.Memcached;
using RpcCacheClient.Redis;
using RpcCentral.Collect;
using RpcCentral.Common;
using RpcCentral.Service.RpcEvent;

namespace RpcCentral.Service
{
    public class CentralService
    {
        public static void Start()
        {
            CacheConfig config = RpcContralConfig.GetCache();
            RpcCacheService.SetVerNum(RpcContralConfig.CacheVerNum);
            RpcCacheService.Init(config, RpcContralConfig.CacheType);
            UnityHelper.RegisterSingle(typeof(ICacheController),typeof(CacheController));
            UnityHelper.RegisterSingle(typeof(IRedisCache), typeof(RedisCacheController));
            UnityHelper.RegisterSingle(typeof(ILocalCacheController), typeof(LocalCacheService));
            UnityHelper.RegisterSingle(typeof(IMemcachedCache), typeof(MemcachedService));
            SqlSugarHelper.SqlSugarService.Init(new SqlSugarContainer());
            UnityHelper.Init();
            IRpcServerCollect server = UnityHelper.Resolve<IRpcServerCollect>();
            server.LoadServer();
            RpcEventService.InitEvent();
            TcpService.TcpService.Start();
        }
    }
}
